import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/archives/app_bar.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/archives/archives_ability_details_item.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/achieves/archieves_ability_detail_entity.dart';
import 'package:flutter_eve_plugin/pages/ye_xiu/archives/actions.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class ArchivesAbilityDetailsPage extends StatefulWidget {
  final String title;

  ArchivesAbilityDetailsPage({Key key, this.title}) : super(key: key);

  _ArchivesAbilityDetailsPageState createState() =>
      _ArchivesAbilityDetailsPageState();
}

class _ArchivesAbilityDetailsPageState
    extends State<ArchivesAbilityDetailsPage> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(
        onInit: (state) => state.dispatch(getAblityData()),
        converter: (store) {
      return AppStateViewModel(
        state: store.state,
      );
    }, builder: (context, vm) {
      ArchievesAbilityDetailEntity data = vm.state.yeXiuState.archivesState.abilityDetailEntity;
      return Container(
        decoration: BoxDecoration(
            image: DecorationImage(
                image:
                    AssetImage(imageUtilYeXiu('archives/icon_archives_bg@3x')),
                fit: BoxFit.fitWidth,
                alignment: Alignment.topCenter)),
        child: Scaffold(
          backgroundColor: Colors.transparent,
          appBar: buildArchivesAppBarTitle(widget.title),
          body: ListView.separated(
            padding: EdgeInsets.only(top: setRatio(20), bottom: setRatio(20)),
            itemCount: data?.propertyList?.length,
            separatorBuilder: (BuildContext context, int index) {
              return SizedBox(
                height: setRatio(16),
              );
            },
            itemBuilder: (BuildContext context, int index) {
              return ArchivesAbilityDetailsItemWidget(
                index: index,data: data,
              );
            },
          ),
        ),
      );
    });
  }
}
